using System;
using Sirenix.OdinInspector;
using UnityEngine;

namespace Modules.SoundEffect
{
    [CreateAssetMenu(fileName = "SoundEffectStore", menuName = "Scriptable Objects/Sound Effect Store")]
    public class SoundEffectStore : ScriptableObject
    {
        [TableList(ShowIndexLabels = true)] [SerializeField] private SoundEffectAgent[] soundEffectAgents;

        public AudioClip GetClip(string label)
        {
            return Array.Find(soundEffectAgents, agent => agent.Label.Equals(label)).Clip;
        }
    }

    [System.Serializable]
    public record SoundEffectAgent
    {
        [SerializeField] private string label;
        [SerializeField] private AudioClip clip;
        public string Label => label.Trim();
        public AudioClip Clip => clip;
    }
}